-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Pad or crop volume using scil_volume_reshape.py
#1019
Conversation
scil_volume_reshape.py
scil_volume_reshape.py
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1019 +/- ##
==========================================
+ Coverage 68.78% 68.84% +0.06%
==========================================
Files 429 431 +2
Lines 22265 22332 +67
Branches 3324 3332 +8
==========================================
+ Hits 15314 15375 +61
- Misses 5665 5670 +5
- Partials 1286 1287 +1
|
Quick discussion with @frheault, can you rename scil_volume_reshape_to_reference.py to scil_volume_reslice_to_reference.py ? |
Good point @arnaudbore, done in 0e925ed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super clear. Thanks for the tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything seems to be working well. I don't have much to say, thanks for renaming the reshape_to_reference for reslice_to_reference.
affine = img.affine | ||
|
||
# Compute the difference between the desired shape and the current shape | ||
diff = (np.array(volume_shape) - np.array(data.shape[:3])) // 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How hard would it be to have an option to be centered on the data's barycenter?
Would it be useful to allow to pad or crop even if the brain is not exactly center?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it could be a nice option but kind of out of scope for this PR. One way to do this without any modification would be to use scil_volume_crop, then pad to the desired shape.
Really for merging @arnaudbore @frheault |
Quick description
This new script allows to pad or crop a volume to a specified resolution (or to match a reference volume). It is complementary to
scil_volume_resample.py
.This will be useful to build machine learning datasets where it is desirable to deal with fixed-size volumes.
Type of change
Check the relevant options.
Provide data, screenshots, command line to test (if relevant)
GDrive
fodf_128.nii.gz was used as the base file.
Checklist